
package com.idealighter.game.games.zjh.handler;

import com.idealighter.game.core.annotation.ResMsgHandler;
import com.idealighter.game.games.zjh.ZjhPlayer;
import com.idealighter.game.games.zjh.message.ResDiscardMsg;
import com.idealighter.game.message.ModuleMsgIdConstant;
import com.idealighter.game.message.core.ResMessage;
import com.idealighter.game.robot.core.Player;
import com.idealighter.game.robot.handler.ResMessageHandler;
import com.idealighter.utils.code.RandCodeUtil;

import java.util.concurrent.TimeUnit;



@ResMsgHandler(ModuleMsgIdConstant.Zjh.RES_DISCARD)
public class ResDiscardHandler implements ResMessageHandler {

  // private static final Logger LOG = LoggerFactory.getLogger(ResDiscardHandler.class);

  @Override
  public void action(Player player, ResMessage message) {
    ResDiscardMsg msg = (ResDiscardMsg) message;
    ZjhPlayer zjhPlayer = (ZjhPlayer) player;

    if (msg.getNextOptPlayerId() == player.playerId) {
      player.schedule(() -> {
        zjhPlayer.bet();
      }, RandCodeUtil.random(1, 10), TimeUnit.SECONDS);
    }
  }
}
